/**
 * 				ServerManager.java
 *				------------
 *		
 *   Author:	bin04017@gmail.com
 *	 Created:	13.12.2006
 *	 Project:	MP3-Sync (Mochito)
 *	 Package:	mochito.serverClasses
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 */
package mochito.serverClasses;

import java.rmi.RemoteException;
import java.util.Set;

import mochito.dataClasses.musicItem.MusicItem;

/**
 * @author bin04017
 *
 */
public class ServerManager {

	private String host;
	
	private ServerRuntime server = null;
	
	public ServerManager(String host){
		this.host = host;
		this.setServer();
	}
	private void setServer(){
		if(server == null){
			try {
				server = new ServerRuntime(host);
			} catch (RemoteException e) {
				System.err.println("Error making ServerRuntime");
			}
		}
	}
	
	public void addMusicItem(MusicItem item) throws RemoteException{
		server.getServerRMI().addMusicItem(item);
	}
	public void addMusicItem(String name, String fileName) throws RemoteException{
		server.getServerRMI().addMusicItem(new MusicItem(name, fileName));
	}
	public Set<String> getMusicItemsNames() throws RemoteException{
		return server.getServerRMI().getMusicItems();
	}
	public void run() {
		server.run();
	}
	public String getMusicItemStartDate(String item) throws RemoteException {
		return server.getServerRMI().getMusicItemStartDate(item);
	}
	public String getMusicItemStartTime(String item) throws RemoteException {
		return server.getServerRMI().getMusicItemStartTime(item);
	}
	public void removeMusicItem(MusicItem item) throws RemoteException {
		server.getServerRMI().removeMusicItem(item);
	}
	public String getMusicItemFile(String item) throws RemoteException{
		return server.getServerRMI().getMusicItemFile(item);
	}
	
}
